finp$="picture.gif"

fout$=finp$+".bin"
fout2$=finp$+".bas"
fout3$=finp$+".zxb"

' converts a 128x96 4c picture into a 'pmode1:screen1,0' binary file
setdisplay(128,96,32,1):paper(8^8-1):ink(0):pen(0):cls
loadimage(finp$,1):pasteicon(0,0,1)

open fout$ for output as #1
open fout2$ for output as #2
open fout3$ for output as #3

print #2,"10 gr:out 128,144"
print #2,"12 for a=0 to 3071"
print #2,"14 read u"
print #2,"16 poke 32768+a,u"
print #2,"18 next"
print #2,"20 goto 20"

print #3,"asm"

for y=0 to 95
  txou$=str$(9000+y)+" data "
  txou2$="  defb "
  for x1=0 to 31
    btv=0:btt=0
    for x2=3 to 0 step -1
      btv=btv*4
      u=point(x1*4+(3-x2),y)
      b=u mod 256: u=int(u/256)
      g=u mod 256: u=int(u/256)
      r=u mod 256: u=int(u/256)
      btt=0
      if r>128 then:btt=1:end if
      if g<128 then:btt=2:end if
      if r>128 and g<128 then:btt=3:end if
      btv=btv+btt
      next
    writebyte(1,btv)
    txou$=txou$+str$(btv)
    if x1<31 then:txou$=txou$+",":end if
    txou2$=txou2$+str$(btv)
    if x1<31 then:txou2$=txou2$+",":end if
 
 
    next
  print #2,txou$
  print #3,txou2$
  next

print #3,"end asm"

close #1
close #2
close #3

'waitkey

